<head th:fragment="headerCss">
    <meta charset="utf-8">
    <title>竞赛管理平台</title>
    <meta content="width=device-width, initial-scale=1.0" name="viewport">
    <meta name="keywords" content=""/>
    <meta name="description"
          content="竞赛管理平台"/>
    <link rel="stylesheet" href="/js/layui/css/layui.css">
    <!-- Bootstrap CSS File -->
    <!--<link href="/lib/bootstrap/css/bootstrap.min.css" rel="stylesheet">-->
    <link rel="stylesheet" href="/css/examination/common.css">
    <link href="/css/font-awesome.css?v=4.4.0"
          th:href="@{/css/font-awesome.css?v=4.4.0}" rel="stylesheet">
    <!-- Google Fonts -->
    <link rel="shortcut icon" href="favicon.ico">
    <link rel="stylesheet" href="/css/swiper-bundle.css">

    <style>
        .ti1{float: left;width: 20%;line-height: 42px;color: #333}
        .ti2{float: right !important;width: 75%;text-align: left !important;}
        #examinationList,.layui-input{border: 0;background: #F2F4F9;border-color: #ccc;border-radius: 5px;color: #666666 !important; font-size: 12px !important;}
        .windowstor{
            background: url("../img/chhyss.png") no-repeat;
            background-size: 100% 100%;
            height: 65%;
            width: 70%;
            margin: 0;
            min-height: 700px !important;
            min-width: 1000px !important;

        }
        .tips{font-size: 25px;color: #E60214;display: none;width: 400px;margin: 30px auto 0;}
        .carousel{width: 435px;}
        .newtoptit{width: 100%;margin: 75px auto 37px; text-align: center;}
        .newtoptit img{width: 128px;height: 126px;display: block;margin: 0 auto;}
        .newaddtips{margin: 0;}

        .leftForm{width: 800px;height: 10px}
        .loginIn{margin-top: 100px;margin-bottom: 140px;text-align: center}
        .loginIn .title{ font-size: 20px;color: #000;text-align: center;
            margin-bottom: 38px;font-weight: bold }
        /*.loginIn .title::after{content: '';display: block;width: 14px;height: 2px;*/
        /*    background: #F8CD00; margin: 8px auto;}*/

        #submitBtn,#submitBtn:hover{
            background: linear-gradient(180deg, #5AAEDF 0%, #2A87C3 100%);
            border-radius: 2px;
            height: 48px;
            line-height: 48px;
        }
        #submitBtn{
            margin-top: 0;
        }
        .item{
            margin-bottom: 14px;
        }
        /*.window_box{margin-top: 100px}*/
        #ticketNumber,#idNumber, #username,#examinationList{text-align: left;padding-left: 18px;}
        /*.main_content.has_back:before {
            background:url("../img/chhyss.png");
        }*/
    </style>
</head>
<body class="signin">

<div class="main_content has_back" style="display: flex;justify-content: center;align-items: center;height: 100%;">
    <div class="windowstor" style="position:relative;    margin-top: 100px;">

        <div class="leftForm"></div>

        <div class="carousel" style="position: absolute;right: 0;height: 100%;display: flex;justify-content: center;align-items: center;width: 50%">

            <div class="tips" id="tips">请升级你的浏览器，该浏览器不支持此考试系统，建议使用谷歌浏览器！(谷歌浏览器可进行正常考试)</div>

            <div class="loginIn" style="margin: 0">
                <img src="/img/jinzhuan.png" width="200" style="margin-bottom: 80px">
                <div class="title">欢迎登录</div>
                <div class="item">
<!--                    <label class="ti1">考试批次</label>-->
                    <select id="examinationList" name="examinationList" class="layui-input" style="cursor:pointer;">
                        <option value="" checked>请选择考试批次</option>
                    </select>
                    <div style="clear: both"></div>
                </div>

                <div class="item num2">
                    <input type="text" id="num2" placeholder="请输入第二次加密" autocomplete="new-password"
                           class="layui-input">
                    <div style="clear: both"></div>
                </div>

                <div class="item num2">
                    <input  type="text" id="randomCipher" placeholder="请输入您的密码" autocomplete="new-password" class="layui-input">
                    <div style="clear: both"></div>
                </div>

<!--                <div class="item">-->
<!--                    <input  type="text" id="username" placeholder="请输入姓名" autocomplete="new-password" class="layui-input">-->
<!--                    <div style="clear: both"></div>-->
<!--                </div>-->

<!--                <div class="item">-->
<!--                    <input type="text" id="idNumber" placeholder="请输入身份证" autocomplete="new-password" class="layui-input">-->
<!--                    <div style="clear: both"></div>-->
<!--                </div>-->

<!--                <div class="item">-->
<!--                    <input type="text" id="ticketNumber" placeholder="请输入手机号码" autocomplete="new-password"-->
<!--                           class="layui-input">-->
<!--                    <div style="clear: both"></div>-->
<!--                </div>-->

                <!--<div class="item" style="text-align: right">-->
                <!--<label ><a href="/examination/abnormal">考试异常恢复</a></label>-->
                <!--</div>-->
                <div class="item">
                    <input type="hidden" th:value="${time}" id="times" />
                    <input type="hidden" th:value="${dates}" id="dates" />
                    <a href="javascript:;" class="layui-btn layui-btn-fluid layui-btn-danger" onclick="login()"
                       id="submitBtn">登&nbsp&nbsp&nbsp&nbsp录</a>
                </div>

            </div>

        </div>

    </div>

</div>

<script>

    function isIE() {
        if (!!window.ActiveXObject || "ActiveXObject" in window)
            return true;
        else
            return false;
    }

    if( isIE() ){
        document.getElementById('tips').style.display = 'block';
    }

</script>

<script src="/js/jquery.min.js?v=2.1.4" th:src="@{/js/jquery.min.js?v='2.1.4'}"></script>
<script src="/js/plugins/layer/layer.min.js" th:src="@{/js/plugins/layer/layer.min.js}"></script>
<script src="/js/swiper-bundle.js"></script>
<script type="text/javascript">

    //回车登录
    var examinationListIntro = null, gather = [] ;
    document.onkeydown =cdk;
    function cdk(){
        if(event.keyCode ==13){
            if(flag) {
                login();
            }

        }
    }
    var id=null;
    var flag = false
    $(function () {

        $.ajax({
            url: "/jzApi/examinations/selExaminationComs",
            type : "get",
            async : false,
            data:{
                competitionType:'1'
            },
            success: function (r) {
                //console.log("r",r)
                if(r.code !=-1){
                    if(window.localStorage){
                        //window.localStorage.setItem("intro",JSON.stringify(r.data));
                        // window.localStorage.setItem("backGroundImage",r.data.backGroundImage);
                    }else{
                        layer.msg("请换浏览器，最佳为谷歌")
                    }
                    examinationListIntro = r.data;
                    for(var p in r.data){
                        $("#examinationList").append("<option value='"+r.data[p].id+"'>"+r.data[p].name+"</option>");
                    }
                    //id = r.data.id
                }else{
                    $("#examinationList").append("<option value=''>"+r.msg+"</option>");
                    $("#submitBtn").attr("disabled",true).css({"pointer-events":"none",'background':'#e1e1e1'});
                }
            }
        });

    });

    function login() {

        let set ;
        let time = 5;
        let severTime;
        set = setInterval(function (){
            flag = false
            $('#submitBtn').attr("disabled",true).css({"pointer-events":"none","background":'#999'}).html('登录'+time+"s");
            time--;
            if( time < 0 ){
                flag = true
                $('#submitBtn').attr({"disabled":false,'style':''}).html('登录');
                clearInterval(set)
            }
        },1000)

        // $.ajax({
        //     type: "POST",
        //     url: "/jzApi/examinations/getNowDateTime",
        //     data: {},
        //     success: function (r) {
        //         severTime = r
        //     }
        // });

        var username = $("#username").val();
        var idNumber = $("#idNumber").val();
        var ticketNumber = $("#ticketNumber").val();
        var examinationId = $("#examinationList").val();

        var randomCipher = $("#randomCipher").val();
        var num2 = $("#num2").val();
        if ('' == examinationId) {
            layer.msg('请选择考试批次');
            return false
        }
        if ('' == username) {
            layer.msg('请输入姓名');
            return false
        }
        if ('' == idNumber) {
            layer.msg('请输入考生编号');
            return false
        }
        if ('' == ticketNumber) {
            layer.msg('请输入准考证号');
            return false
        }
        $.ajax({
            type: "POST",
            url:  "/jzApi/examinations/loginExamination",
            data: {id:$.trim(examinationId),name:$.trim(username) , idNumber:$.trim(idNumber), ticketNumber:$.trim(ticketNumber),randomCipher:randomCipher,num2:num2 },
            success: function (r) {

                if (r.code == 0) {
                    let userinfo = JSON.parse(window.localStorage.getItem("info"));
                    if( false){
                    // if( userinfo ){
                        window.localStorage.setItem("info",JSON.stringify(r.data));
                        if( r.data.ticketNumber == userinfo.ticketNumber ){
                            location.href = '/examination/startExam'
                        }else{
                            localStorage.clear();
                        }
                    }

                    if(window.localStorage){
                        for(var e in examinationListIntro){
                            if(examinationListIntro[e].id == examinationId){
                                // window.localStorage.setItem("intro"+r.data.idCard,JSON.stringify(examinationListIntro[e]));
                                window.localStorage.setItem("intro",JSON.stringify(examinationListIntro[e]));
                                break;
                            }
                        }
                        window.localStorage.setItem("info",JSON.stringify(r.data));
                        window.localStorage.setItem("nowDate",r.data.nowDate);
                        window.localStorage.setItem("times",JSON.stringify($('#times').val()));
                        window.localStorage.setItem("dates",JSON.stringify($('#dates').val()));
                    }else{
                        layer.msg("请换浏览器，最佳为谷歌")
                    }

                    // let startTime = new Date(examinationListIntro[0].startTime).getTime() + (60*15*1000);
                    // let startString = new Date(examinationListIntro[0].startTime).getTime();
                    // let thiServeTime = new Date( severTime ).getTime();
                    //
                    // if( thiServeTime < startString ){
                    //     layer.msg('还没到考试时间')
                    //     return false;
                    // }
                    // if( startTime >= startString ){
                        location.href = '/examination/startExam'
                    // }else{
                    //     layer.msg('考试时间已超过15分钟')
                    // }

                } else {
                    layer.msg(r.msg);
                }
            }
        });
    }

</script>
</body>





